<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8">
		<title></title>
		<script>
			function cal() {
				var a = 3;

				var nums = document.getElementsByName("num");
				var result = document.getElementsByName("rs");

				var gz = parseFloat(nums[0].value);

				if (gz <= 3500) {
					result[0].value = 0;

				} else if (gz > 3500 && gz <= 8000) {
					result[0].value = (gz - 3500) * 0.02;

				} else if (gz > 8000 && gz <= 20000) {
					result[0].value = ((gz - 8000) * 0.05) + ((gz - 3500) * 0.2);

				} else if (gz > 20000) {
					result[0].value = ((gz - 20000) * 0.1) + ((gz - 8000) * 0.05) + ((gz - 3500) * 0.02);

				}
			}
		</script>
	</head>
	<body>

		输入工资：
		<input type="number" name="num" value="" />
		<button id="btn" onclick="cal()">计算</button>
		<input type="text" name="rs" value="" /><br>

	</body>
</html>
